package com.atguigu.gmall.weball.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.weball.feign.CategoryFeignClient;
import com.atguigu.gmall.weball.vo.CategoryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

@Controller
public class IndexController {
    @Autowired
    CategoryFeignClient categoryFeignClient;
    @GetMapping("/")
    public String indexPage(Model model){
        Result<List<CategoryVo>> categoryTreeData = categoryFeignClient.getCategoryTreeData();
        List<CategoryVo> vos = categoryTreeData.getData();
        model.addAttribute("list",vos);
        return "index/index";
    }
}
